package KKTriangle;

public class KKTriangleProgram {

	public static void main(String args[])
	{
		if(args.length != 3)
		{
			System.out.println("Please enter exactly 3 sides");
		}
		else
		{
			int side1 = Integer.parseInt(args[0]);
			int side2 = Integer.parseInt(args[1]);
			int side3 = Integer.parseInt(args[2]);
			
			if(side1 > 0 || side2 > 0 || side3 > 0)
			{
				String triangleType = determineType(side1, side2, side3);
				
				System.out.println("Triangle is a " + triangleType + " triangle");
				
				boolean rightTriangle = isRightTriangle(side1, side2, side3);
				if(rightTriangle)
				{
					System.out.println("Triangle is a right triangle");
				}
				else
				{
					System.out.println("Triangle is not a right triangle");
				}
			}
			else
			{
				System.out.println("Invalid sides. All sides must be greater than zero");
			}
		}
	}
	
	public static String determineType(int side1, int side2, int side3)
	{
		if(side1 == side2 && side1 == side3)
		{
			return("Equilateral");
		}
		else if ((side1 != side2 && side1 == side3)||(side1 != side3 && side2 == side3)|| (side1 !=side3 && side1 == side2))
		{
			return("Isosceles");
		}
		else
		{
			return("Scalene");
		}		
	}
	
	public static boolean isRightTriangle(int side1, int side2, int side3)
	{
		if(side3 == (Math.sqrt(Math.pow(side1,2) + Math.pow(side2,2))))
		{
			return true;
		}
		else if(side1 == (Math.sqrt(Math.pow(side2,2) + Math.pow(side3,2))))
		{
			return true;
		}
		else if(side2 == (Math.sqrt(Math.pow(side1,2) + Math.pow(side3,2))))
		{
			return true;
		}
		return false;
	}
}
